package com.adong.controller;


import com.adong.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.validation.Valid;

@Controller
public class UserController {

    @RequestMapping("/logOn")
    public String logOn(@Valid User user, ModelAndView modelAndView) {
        System.out.println(user);
        if ("com.adong".equals(user.getUserName()) && "com.adong".equals(user.getPassWord())) {
            modelAndView.addObject("user",user);
            return "/success.jsp";
        } else {
            return "redirect:/index.jsp";
        }
    }
}
